/*   1:    */ package com.atomikos.datasource.xa;
/*   2:    */ 
/*   3:    */ import com.atomikos.datasource.ResourceException;
/*   4:    */ import com.atomikos.datasource.ResourceTransaction;
/*   5:    */ import com.atomikos.icatch.CompositeTransaction;
/*   6:    */ import java.util.Enumeration;
/*   7:    */ import java.util.Hashtable;
/*   8:    */ import java.util.Stack;
/*   9:    */ 
/*  10:    */ class SiblingMapper
/*  11:    */ {
/*  12:    */   protected Hashtable siblings_;
/*  13:    */   protected XATransactionalResource res_;
/*  14:    */   protected String root_;
/*  15:    */   
/*  16:    */   SiblingMapper(XATransactionalResource res, String root)
/*  17:    */   {
/*  18: 52 */     this.siblings_ = new Hashtable();
/*  19: 53 */     this.res_ = res;
/*  20: 54 */     this.root_ = root;
/*  21:    */   }
/*  22:    */   
/*  23:    */   protected ResourceTransaction map(CompositeTransaction ct)
/*  24:    */     throws ResourceException, IllegalStateException
/*  25:    */   {
/*  26: 60 */     Stack errors = new Stack();
/*  27: 61 */     XAResourceTransaction last = null;
/*  28:    */     try
/*  29:    */     {
/*  30: 64 */       last = (XAResourceTransaction)this.siblings_.get(ct);
/*  31: 65 */       if ((last == null) || (this.res_.usesWeakCompare()) || (this.res_.acceptsAllXAResources()) || (last.isActive()))
/*  32:    */       {
/*  33: 69 */         Enumeration enumm = this.siblings_.elements();
/*  34: 70 */         if (enumm.hasMoreElements()) {
/*  35: 71 */           last = (XAResourceTransaction)enumm.nextElement();
/*  36:    */         }
/*  37: 73 */         if ((last == null) || (!ct.isSerial()) || (this.res_.usesWeakCompare()) || (this.res_.acceptsAllXAResources()) || (last.isActive()))
/*  38:    */         {
/*  39: 85 */           last = new XAResourceTransaction(this.res_, ct, this.root_);
/*  40:    */           
/*  41:    */ 
/*  42: 88 */           this.siblings_.put(ct, last);
/*  43:    */         }
/*  44:    */       }
/*  45:    */     }
/*  46:    */     catch (Exception e)
/*  47:    */     {
/*  48: 95 */       errors.push(e);
/*  49: 96 */       throw new ResourceException("ResourceTransaction map failure", errors);
/*  50:    */     }
/*  51:100 */     ct.addParticipant(last);
/*  52:    */     
/*  53:102 */     return last;
/*  54:    */   }
/*  55:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.SiblingMapper
 * JD-Core Version:    0.7.0.1
 */